# Contributor: Fabio Ribeiro <fabiorphp@gmail.com>
# Maintainer: Fabio Ribeiro <fabiorphp@gmail.com>
pkgname=php7-pecl-memcached
_pkgreal=memcached
pkgver=3.1.5
pkgrel=2
pkgdesc="PHP extension for interfacing with memcached via libmemcached library"
url="https://pecl.php.net/package/memcached"
arch="all"
license="PHP-3.01"
depends="php7-session php7-pecl-igbinary"
makedepends="php7-dev zlib-dev libmemcached-dev cyrus-sasl-dev"
source="$pkgname-$pkgver.tgz::https://pecl.php.net/get/$_pkgreal-$pkgver.tgz"
builddir="$srcdir/$_pkgreal-$pkgver"
provides="php7-memcached=$pkgver-r$pkgrel" # for backward compatibility
replaces="php7-memcached" # for backward compatibility

build() {
	phpize7
	./configure \
		--prefix=/usr \
		--with-php-config=php-config7 \
		--enable-memcached-igbinary \
		--disable-memcached-sasl
	make
}

check() {
	# Tests require memcached server, basic check
	php7 -d extension="$builddir"/modules/$_pkgreal.so --ri $_pkgreal
}

package() {
	local confdir="$pkgdir/etc/php7/conf.d"

	make INSTALL_ROOT="$pkgdir" install

	mkdir -p "$confdir"
	echo "extension=$_pkgreal.so" > "$confdir"/20_$_pkgreal.ini
}

sha512sums="87d5fd079fcaad81139785d6766da71b23a1a0fe907d4b22f3a787af148a20412c11df11c4d98c165241658baf0d87c8a6b29de15db07a0f9d1fabc8aec8f0e9  php7-pecl-memcached-3.1.5.tgz"
